﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MyEntitiesControlNew.ascx.vb"
    Inherits="Controls_MyEntitiesControl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<table>
    <tr>
        <td valign="top">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                DataSourceID="ObjectDataSource1">
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                        SortExpression="ID" Visible="False" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="CompanyRegNo" HeaderText="Co. Reg. #" SortExpression="CompanyRegNo" />
                    <asp:BoundField DataField="VATRegNO" HeaderText="VAT Reg #" SortExpression="VATRegNO" />
                    <asp:BoundField DataField="DateCreated" HeaderText="Created" SortExpression="DateCreated" />
                    <asp:BoundField DataField="EntityTypeId" HeaderText="EntityTypeId" SortExpression="EntityTypeId"
                        Visible="False" />
                    <asp:CheckBoxField DataField="Active" HeaderText="Active" SortExpression="Active"
                        Visible="False" />
                </Columns>
            </asp:GridView>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
                SelectMethod="GetData" TypeName="LogginsLogDSTableAdapters.usp_GetEntityListFull_ByPersonIdTableAdapter">
                <SelectParameters>
                    <asp:Parameter Name="PersonId" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </td>
        <td valign="top">
            <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
                DataSourceID="ObjectDataSource2" GridLines="Both">
                <EditItemTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                Business Name:
                            </td>
                            <td>
                                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' MaxLength="50" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Company Reg No:
                            </td>
                            <td>
                                <asp:TextBox ID="CompanyRegNoTextBox" runat="server" Text='<%# Bind("CompanyRegNo") %>'
                                    MaxLength="10" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                VAT Reg No:
                            </td>
                            <td>
                                <asp:TextBox ID="VATRegNoTextBox" runat="server" Text='<%# Bind("VATRegNo") %>' MaxLength="10" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Entity Type:
                            </td>
                            <td>
                                <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
                                    DataTextField="Name" DataValueField="Id" Width="132px" AppendDataBoundItems="True"
                                    SelectedValue='<%# Bind("EntityTypeId") %>'>
                                    <asp:ListItem Value="0">Please Pick one...</asp:ListItem>
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    DeleteCommand="usp_lkp_EntityTypeDelete" DeleteCommandType="StoredProcedure"
                                    InsertCommand="usp_lkp_EntityTypeInsert" InsertCommandType="StoredProcedure"
                                    SelectCommand="usp_lkp_EntityTypeSelect_ALL" SelectCommandType="StoredProcedure"
                                    UpdateCommand="usp_lkp_EntityTypeUpdate" UpdateCommandType="StoredProcedure">
                                    <DeleteParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </DeleteParameters>
                                    <InsertParameters>
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </InsertParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </UpdateParameters>
                                </asp:SqlDataSource>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="Cancel" />
                    &nbsp;<br />
                    <br />
                    &nbsp;<asp:TextBox ID="DateCreatedTextBox" runat="server" Text='<%# Bind("DateCreated") %>'
                        Style="visibility: hidden;" />
                    <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' Style="visibility: hidden;" />
                    <%--                    <asp:TextBox ID="EntityTypeIdTextBox" runat="server" Text='<%# Bind("EntityTypeId") %>'
                        Style="visibility: hidden;" />:
                    --%>
                    <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Bind("Active") %>'
                        Style="visibility: hidden;" />
                    <br />
                </EditItemTemplate>
                <InsertItemTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                Business Name:
                            </td>
                            <td>
                                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' MaxLength="50" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Company Reg No:
                            </td>
                            <td>
                                <asp:TextBox ID="CompanyRegNoTextBox" runat="server" Text='<%# Bind("CompanyRegNo") %>'
                                    MaxLength="10" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                VAT RegNo:
                            </td>
                            <td>
                                <asp:TextBox ID="VATRegNoTextBox" runat="server" Text='<%# Bind("VATRegNo") %>' MaxLength="11" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Entity Type:
                            </td>
                            <td>
                                <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1"
                                    DataTextField="Name" DataValueField="Id" Width="132px" SelectedValue='<%# Bind("EntityTypeId") %>'>
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    DeleteCommand="usp_lkp_EntityTypeDelete" DeleteCommandType="StoredProcedure"
                                    InsertCommand="usp_lkp_EntityTypeInsert" InsertCommandType="StoredProcedure"
                                    SelectCommand="usp_lkp_EntityTypeSelect_ALL" SelectCommandType="StoredProcedure"
                                    UpdateCommand="usp_lkp_EntityTypeUpdate" UpdateCommandType="StoredProcedure">
                                    <DeleteParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </DeleteParameters>
                                    <InsertParameters>
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </InsertParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </UpdateParameters>
                                </asp:SqlDataSource>
                                <td>
                                    &nbsp;
                                </td>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                        Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="Cancel" />
                    <asp:TextBox ID="DateCreatedTextBox" runat="server" Text='<%# Bind("DateCreated") %>'
                        Style="visibility: hidden;" />
                    <br />
<%--                    <asp:TextBox ID="EntityTypeIdTextBox" runat="server" Text='<%# Bind("EntityTypeId") %>'
                        Style="visibility: hidden;" />
--%>                    <br />
                    <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Bind("Active") %>'
                        Style="visibility: hidden;" />
                </InsertItemTemplate>
                <ItemTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                Business Name :
                            </td>
                            <td>
                                <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Company RegNo:
                            </td>
                            <td>
                                <asp:Label ID="CompanyRegNoLabel" runat="server" Text='<%# Bind("CompanyRegNo") %>' />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                VAT Reg No:
                            </td>
                            <td>
                                <asp:Label ID="VATRegNoLabel" runat="server" Text='<%# Bind("VATRegNo") %>' />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Business Type:
                            </td>
                            <td>
                                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                                    DataTextField="Name" DataValueField="Id" Width="132px" AppendDataBoundItems="True"
                                    Enabled="false" SelectedValue='<%# Bind("EntityTypeId") %>'>
                                    <asp:ListItem Value="0">Pick one please...</asp:ListItem>
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    SelectCommand="usp_lkp_EntityTypeSelect_ALL" SelectCommandType="StoredProcedure"
                                    DeleteCommand="usp_lkp_EntityTypeDelete" DeleteCommandType="StoredProcedure"
                                    InsertCommand="usp_lkp_EntityTypeInsert" InsertCommandType="StoredProcedure"
                                    UpdateCommand="usp_lkp_EntityTypeUpdate" UpdateCommandType="StoredProcedure">
                                    <DeleteParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </DeleteParameters>
                                    <InsertParameters>
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </InsertParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </UpdateParameters>
                                </asp:SqlDataSource>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <br />
                    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit" />
                    &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Delete" />
                    <asp:ConfirmButtonExtender ID="DeleteButton_ConfirmButtonExtender" runat="server"
                        ConfirmText="Delete entity ?" Enabled="True" TargetControlID="DeleteButton">
                    </asp:ConfirmButtonExtender>
                    &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                        Text="New" />
                    &nbsp;<asp:Label ID="DateCreatedLabel" runat="server" Text='<%# Bind("DateCreated") %>'
                        Style="visibility: hidden;" />
                    <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' Style="visibility: hidden;" />
                    &nbsp;<asp:Label ID="EntityTypeIdLabel" runat="server" Text='<%# Bind("EntityTypeId") %>'
                        Style="visibility: hidden;" />
                    <br />
                    <asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Bind("Active") %>'
                        Enabled="false" Style="visibility: hidden;" />
                    <br />
                </ItemTemplate>
            </asp:FormView>
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" DeleteMethod="Delete"
                InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataBy"
                TypeName="LogginsLogDSTableAdapters.usp_EntityTableAdapter" UpdateMethod="Update">
                <DeleteParameters>
                    <asp:Parameter Name="EntityID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="CompanyRegNo" Type="String" />
                    <asp:Parameter Name="DateCreated" Type="DateTime" />
                    <asp:Parameter Name="VATRegNo" Type="String" />
                    <asp:Parameter Name="EntityTypeId" Type="Int32" />
                    <asp:Parameter Name="Active" Type="Boolean" />
                    <asp:Parameter Direction="InputOutput" Name="EntityId" Type="Object" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="EntityID" PropertyName="SelectedValue"
                        Type="Int32" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Name" Type="String" />
                    <asp:Parameter Name="CompanyRegNo" Type="String" />
                    <asp:Parameter Name="DateCreated" Type="DateTime" />
                    <asp:Parameter Name="VATRegNo" Type="String" />
                    <asp:Parameter Name="EntityTypeId" Type="Int32" />
                    <asp:Parameter Name="Active" Type="Boolean" />
                    <asp:Parameter Name="Original_ID" Type="Int32" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
</table>
